package com.wy2.springcloud.sample.rabbitmq.controller;

import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wy2.springcloud.sample.rabbitmq.mqbinder.RabbitMQClient;

@RestController
public class IndexController {

	@Autowired
	private RabbitMQClient rabbitMQClient;
	
	@Value("${server.port}")
	private String port;
	
	@GetMapping("/")
	public String index() {
		
		Random rnd=new Random();
		int rndNumber=rnd.nextInt(100)+1;
		rabbitMQClient.send("大家好啊"+String.valueOf(rndNumber));
		
		return "success-"+port;
	}
}
